<?php

namespace app\supplier\controller\stall;

use app\Request;
use app\supplier\controller\Controller;
use app\supplier\model\stall\Product as ProductModel;

class Product extends Controller
{

    public function index(Request $request)
    {
        $id = $request->param('sid') ?? 0;
        $cateid = $request->param('category_id') ?? 0;
        $Product = new ProductModel();
        $list = $Product->getProcuteList($id,$cateid, $this->getSupplierId());
        return $this->renderSuccess('', compact('list'));
    }

    public function changestatus()
    {
        $postData = $this->request->post();
        $model = new ProductModel();
        if ($model->setStatus($postData)) {
            return $this->renderSuccess('编辑成功');
        }
        return $this->renderError($model->getError() ?: '编辑失败');
    }

}